<div class="row">
    <div class="col-lg-12">
        <div class="card">
            <div class="card-body text-lg-right m-t-10 m-b-10">
                <button type="button" class="btn btn-primary m-b-10 m-l-5"
                        onclick="window.location.href = 'index.php?r=post/attachmentfile'">新增文件
                </button>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <form method="post" id="form_post">
                        <input type="hidden" name="post_id">
                        <input type="hidden" name="action_type" value="delete">
                        <table class="table">
                            <thead>
                            <tr>
                                <th width="60%">标题</th>
                                <th width="20%">创建时间</th>
                                <th width="20%">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php
                            foreach ($list as $item) {
                                ?>
                                <tr>
                                    <td><?php echo $item['title']; ?></td>
                                    <td><?php echo $item['createtime']; ?></td>
                                    <td>
                                        <button type="button" class="btn btn-primary btn-sm m-l-5"
                                                onclick="edit(<?php echo $item['post_id']; ?>)">编辑
                                        </button>
                                        <button type="button" onclick="del(<?php echo $item['post_id']; ?>)" class="btn btn-danger btn-sm m-l-5">删除</button>
                                    </td>
                                </tr>
                                <?php
                            }
                            ?>
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!-- /# column -->
</div>
<!-- /# row -->
<script>
    function edit(post_id) {
        $("input[name=post_id]").val(post_id);
        $("#form_post").attr("action","index.php?r=post/attachmentfile");
        $("#form_post").submit();
    }
    function del(post_id) {
        $("input[name=post_id]").val(post_id);
        $("#form_post").attr("action","index.php?r=post/file");
        $("#form_post").submit();
    }
</script>